package com.obj;

public class Person {
	private String name;
	private String location;
	
	Person(String name)
	{
		this.name = name;
	}
	
	Person(String name,String location)
	{
		this.name = name;
		this.location = location;
	}
	
	public String getName()
	{
		return this.name;
	}
	
	public String getLocation()
	{
		return this.location;
	}
	
	String info()
	{
		return ("id = " + this.name+";"+"age = "+this.location);
	}
	
	public boolean equals(Object obj)
	{
		if(obj == null) 
			return false;
		else 
		{
			if(obj instanceof Person)
		    {
			       Person tmpPerson = (Person)obj;
			       if((tmpPerson.getName()).equals(this.name) 
			    		   && (tmpPerson.getLocation()).equals(this.location))
			       {
			    	   return true;
			       }
			       return false;
		    }
			return false;
		}
		
	}
	
	public static void main(String args[])
	{
		Student s = new Student("zhangsan","Xi'an","XiDian");
		Student s1 = new Student("zhangsan","Xi'an","XiDian");
		System.out.println(s.equals(s1));
	}
}

class Student extends Person
{
	private String school;
	
	Student(String name,String school) {
		//super(name);
		// TODO Auto-generated constructor stub
		this(name,"BeiJing",school);
	}
	
	Student(String name,String location,String school)
	{
		super(name,location);
		this.school = school;
	}
	
	String info()
	{
		return (super.info() + ";school = " +this.school);
	}
	
}
